package personal.domain.accounting;

import java.io.Serializable;
import java.math.BigDecimal;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

@Entity
@Table (name="monthly_category_total")
@NamedQueries({
	@NamedQuery(name=MonthlyCategoryTotal.UPDATE_MONTHLY_CAT_TOTAL, query="update MonthlyCategoryTotal set total = total + (:totalDiff) where ieCategoryId=:categoryId and calendarId=:calendarId"),
	@NamedQuery(name= MonthlyCategoryTotal.GET_MONTHLY_CAT_TOTAL_FOR_CALENDARS, query="select tot from MonthlyCategoryTotal tot where tot.calendarId in (:calendarIdList) order by tot.calendarId asc")
})
public class MonthlyCategoryTotal implements Serializable {
	private static final long serialVersionUID = 1L;
	public static final String UPDATE_MONTHLY_CAT_TOTAL = "MonthlyCategoryTotal.updateForMonth";
	public static final String GET_MONTHLY_CAT_TOTAL_FOR_CALENDARS = "MonthlyCategoryTotal.getForCalendars";
	private Long calendarId;
	private Long ieCategoryId;
	private BigDecimal total;
	
	@Id
	@Column (name="calendar_id", length=11, unique=false, nullable=false, insertable=true, updatable=true)
	public Long getCalendarId() {
		return calendarId;
	}
	public void setCalendarId(Long calendarId) {
		this.calendarId = calendarId;
	}
	@Id
	@Column (name="ie_category_id", length=11, unique=false, nullable=false, insertable=true, updatable=true)
	public Long getIeCategoryId() {
		return ieCategoryId;
	}
	public void setIeCategoryId(Long ieCategoryId) {
		this.ieCategoryId = ieCategoryId;
	}
	@Column (name="total", unique=false, nullable=false, insertable=true, updatable=true)
	public BigDecimal getTotal() {
		return total;
	}
	public void setTotal(BigDecimal total) {
		this.total = total;
	}
	
}
